package com.mnt.washio.adapters;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.mnt.washio.R;
import com.mnt.washio.views.CustomFontTextView;

public class MenuListAdapter extends BaseAdapter {

	private Context mContext;
	private String[] mMenuIcons, mMenuTexts;
	private int resourceId;

	public MenuListAdapter(Context mContext, String[] mMenuIcons,
			String[] mMenuTexts, int resourceId) {
		this.mContext = mContext;
		this.mMenuIcons = mMenuIcons;
		this.mMenuTexts = mMenuTexts;
		this.resourceId = resourceId;
	}

	@Override
	public int getCount() {
		return mMenuIcons.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			LayoutInflater mInflater = (LayoutInflater) mContext
					.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
			convertView = mInflater.inflate(resourceId, null);
		}

		ImageView imgIcon = (ImageView) convertView.findViewById(R.id.imv_icon);
		CustomFontTextView txtTitle = (CustomFontTextView) convertView
				.findViewById(R.id.tv_text);

		int resId = mContext.getResources().getIdentifier(mMenuIcons[position],
				"drawable", mContext.getPackageName());
		imgIcon.setImageResource(resId);
		txtTitle.setText(mMenuTexts[position]);

		return convertView;
	}

}
